<template>
  <div class="wrap">
    <div class="list">
      <div class="col" v-for="item in list" :key="item.id">
        <router-link
          :to="{
            path: '/caseDetail',
            query: {
              id: item.id,
            },
          }"
        >
          <div class="item">
            <div class="imgDiv">
              <img :src="item.image" alt="" />
            </div>
            <div class="text">
              <div class="title">{{ item.title }}</div>
              <div class="desc ovh2">
                {{ item.description }}
              </div>
              <div class="bottom">
                <span>发布时间：{{ item.publishtime_text }}1</span>
                <div class="btn">查看详情</div>
              </div>
            </div>
          </div></router-link
        >
      </div>
    </div>
    <div class="no_data" v-if="total == 0">
      <img src="@/assets/empty.png" />
     </div>
    <pagination
       v-if="total > 0"
      :total="total"
      :currentPage="currentPage"
      :pageSize="10"
      @handleCurrentChange="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "IndexView",
  data() {
    return { id: "", total: 0, currentPage: 1, list: [] };
  },
  components: {
    pagination: () => import("@/components/pagination.vue"),
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.$post("cases/list", { page: this.currentPage, rows: 10 }).then(
        (res) => {
          this.list = res.data.data;
          this.total = res.data.total;
        }
      );
    },
    handleCurrentChange(page) {
      this.currentPage = page;
      this.getList();
    },
  },
};
</script>

<style scoped lang="scss">
.list {
  margin-top: 30px;
  .col {
    padding: 10px 0;
    .item {
      background: #fff;
      border: 1px solid #ebebeb;
      padding: 20px;
      display: flex;
      align-items: center;
      .imgDiv {
        width: 266px;
        height: 200px;
      }
      .text {
        width: calc(100% - 266px);
        padding-left: 30px;
        font-size: 14px;
        .title {
          font-size: 24px;
        }
        .desc {
          color: #999;
          margin: 15px 0;
        }
        .bottom {
          display: flex;
          align-items: center;
          justify-content: space-between;
        }
        span {
          color: #999;
        }
        .btn {
          color: #fff;
          width: 72px;
          background: linear-gradient(-89deg, #ef3e91, #f4743c);
          border-radius: 4px;
          text-align: center;
          line-height: 28px;
        }
      }
    }
  }
}
.no_data{
  text-align: center;
  padding: 100px 0;
}
@media screen and (max-width: 768px) {
  .list {
    margin-top: 15px;
    .col {
      padding: 8px 0;
      .item {
        padding: 10px;
        .imgDiv {
          width: 30%;
          height: 100px;
        }
        .text {
          width: 70%;
          padding-left: 10px;
          font-size: 14px;
          .title {
            font-size: 16px;
          }
          .desc {
            color: #999;
            margin: 8px 0;
            display: none;
          }
          .bottom {
            display: block;
            font-size: 12px;
            margin-top: 5px;
          }
          span {
            color: #999;
          }
          .btn {
            color: #fff;
            width: 72px;
            background: linear-gradient(-89deg, #ef3e91, #f4743c);
            border-radius: 4px;
            text-align: center;
            line-height: 28px;
            margin-top: 10px;
          }
        }
      }
    }
  }
}
</style>
